package com.af.monitorModule.controller.task;

import com.af.monitorModule.generator.entity.TimedTaskResult;
import com.af.monitorModule.generator.service.TimedTaskResultService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/taskResult")
public class ResultController {

    @Autowired
    private TimedTaskResultService timedTaskResultService;

    /**
     * 任务执行结果上报
     * @param timedTaskResult
     * @return
     */
    @PostMapping("/push")
    public JSONObject setResult(@RequestBody TimedTaskResult timedTaskResult){
        return timedTaskResultService.setResult(timedTaskResult);
    }

    /**
     * 任务管理界面查询任务执行历史
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public JSONObject getResult( @PathVariable String id){
        return timedTaskResultService.getResult(id);
    }
}
